package org.cis.jproyinv.proyecto.vista;

import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import org.cis.jproyinv.proyecto.modelo.ProyectoInvestigacion;
import org.cis.jproyinv.proyecto.negocio.AdministrarProyectoInvestigacionUCController;
import org.jdesktop.observablecollections.ObservableList;

public class ProyectosCumplidos extends javax.swing.JDialog {

    public AdministrarProyectoInvestigacionUCController proyectoUCC = new AdministrarProyectoInvestigacionUCController();

    /** Creates new form ProyectosCumplidos */
    public ProyectosCumplidos() {
        super(new javax.swing.JFrame(), true);
        initComponents();
        this.setLocationRelativeTo(this);
        try {
            listObservableproy.clear();
            listObservableproy.addAll(proyectoUCC.cumplidos());
            tblProyectosCumplidos.repaint();
        } catch (ArrayIndexOutOfBoundsException e) {
            JOptionPane.showMessageDialog(this, "Aún no hay proyectos por cumplirse");
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        panelImage1 = new org.edisoncor.gui.panel.PanelImage();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblProyectosCumplidos = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setAlwaysOnTop(true);
        setName("Form"); // NOI18N
        setResizable(false);

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(jproyinv.JproyinvApp.class).getContext().getResourceMap(ProyectosCumplidos.class);
        panelImage1.setIcon(resourceMap.getIcon("panelImage1.icon")); // NOI18N
        panelImage1.setName("panelImage1"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        tblProyectosCumplidos.setName("tblProyectosCumplidos"); // NOI18N

        org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${listObservableproy}");
        org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, eLProperty, tblProyectosCumplidos);
        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${tema}"));
        columnBinding.setColumnName("Tema");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${cronograma.fechaInicio}"));
        columnBinding.setColumnName("Cronograma.fecha Inicio");
        columnBinding.setColumnClass(java.util.Date.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${cronograma.fechaFin}"));
        columnBinding.setColumnName("Cronograma.fecha Fin");
        columnBinding.setColumnClass(java.util.Date.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${cronograma.fechaProrroga}"));
        columnBinding.setColumnName("Cronograma.fecha Prorroga");
        columnBinding.setColumnClass(java.util.Date.class);
        columnBinding.setEditable(false);
        bindingGroup.addBinding(jTableBinding);
        jTableBinding.bind();
        jScrollPane1.setViewportView(tblProyectosCumplidos);
        tblProyectosCumplidos.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tblProyectosCumplidos.columnModel.title0")); // NOI18N
        tblProyectosCumplidos.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("tblProyectosCumplidos.columnModel.title1")); // NOI18N
        tblProyectosCumplidos.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("tblProyectosCumplidos.columnModel.title3")); // NOI18N
        tblProyectosCumplidos.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("tblProyectosCumplidos.columnModel.title4")); // NOI18N

        javax.swing.GroupLayout panelImage1Layout = new javax.swing.GroupLayout(panelImage1);
        panelImage1.setLayout(panelImage1Layout);
        panelImage1Layout.setHorizontalGroup(
            panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 510, Short.MAX_VALUE)
                .addContainerGap())
        );
        panelImage1Layout.setVerticalGroup(
            panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelImage1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelImage1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                ProyectosCumplidos dialog = new ProyectosCumplidos();
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private org.edisoncor.gui.panel.PanelImage panelImage1;
    private javax.swing.JTable tblProyectosCumplidos;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
    private List<ProyectoInvestigacion> listaproy = new ArrayList();
    private ObservableList<ProyectoInvestigacion> listObservableproy = org.jdesktop.observablecollections.ObservableCollections.observableList(listaproy);

    public ObservableList<ProyectoInvestigacion> getListObservableproy() {
        return listObservableproy;
    }

    public void setListObservableproy(ObservableList<ProyectoInvestigacion> listObservableproy) {
        this.listObservableproy = listObservableproy;
    }
}
